package com.webdemo09.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.webdemo09.pojo.User;
import com.webdemo09.service.UserService;

public class UpdateUser extends ActionSupport {
	private static final long serialVersionUID = 1L;
	private String flag;
	private User user;
	private int id;
	private UserService userService;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getFlag() {
		return flag;
	}
	public void setFlag(String flag) {
		this.flag = flag;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public UserService getUserService() {
		return userService;
	}
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	@Override
	public String execute() throws Exception {
		if("ui".equals(flag)){
			User user = userService.getUser(id);
			ActionContext.getContext().put("user", user);
			return SUCCESS;
		}else{
			userService.updateUser(user);
			return "show";
		}
	}
	
}
